<!DOCTYPE html>
<html lang="en" xmlns:th="http://www/thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户登录页</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

    <style>
        b{
            font-weight: bolder;
            color: red;
        }
    </style>
    <link rel="stylesheet" href="/plugins/bootstraptable/bootstrap-table.min.css">

</head>
<body>
<div class="container-fluid">
    <div class="panel panel-default">
        <div class="panel-heading">Panel heading without title</div>
        <div class="panel-body">
            <form>
                <div class="form-group">
                    <label for="username">用户名：</label>
                    <input type="email" class="form-control" id="username" name="uesrname" placeholder="用户名">
                </div>
                <div class="form-group">
                    <label for="password">密码：</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码">
                </div>

                <button type="submit" class="btn btn-default" onclick="login();">登录</button>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" >
    function login(){
        var name=$("#username").val();

        var password=$("#password").val();

        $.ajax({
            url:"/student/webapi/login/user",
            data:{
                username:name,
                password:password
            }
        }).done(function (rs){
            if(rs>=0){
                window.location.href="/student/list";
            }else{
                alert("出错了，用户名和密码是乱写的吗？");
            }
        });
    }
</script>
</body>
</html>